package it.uni.bo.monitoring.sla.parser;

import it.uni.bo.monitoring.sla.chain.availability.Reliability;
import it.uni.bo.monitoring.sla.chain.latency.Latency;
import it.uni.bo.monitoring.sla.chain.throughput.Throughput;

import java.util.HashMap;
import java.util.List;

import org.apache.log4j.Logger;


public abstract class SlaBean{
	
	protected static Logger l =Logger.getLogger("monitoring.sla.parser.SlaBean");

	private static HashMap<String, Class> slaLanguage;
	
	public static SlaBean getSlaBean(String slaName){
		try {
			Class a = slaLanguage.get(slaName);
			if(a!=null){
				Object o = a.newInstance();
				if(o instanceof SlaBean){
					return (SlaBean)o;
				}
			}
		} catch (InstantiationException e) {
			l.error(e.getMessage());
		} catch (IllegalAccessException e) {
			l.error(e.getMessage());
		}
		return null;
	}
	
	public static void addSlaLanguage(String slaName, Class classe){
		if(slaLanguage==null)
			slaLanguage=new HashMap<String, Class>();
		slaLanguage.put(slaName, classe);
	}
	public abstract void parse(byte[] b);
	public abstract List<Throughput> getThroughputList();
	public abstract List<Latency> getLatencyList();
	public abstract List <Reliability>getReliabilityList();

}
